package net.atomarrow.upload;
 
import java.io.File;
import java.util.UUID;

import com.oreilly.servlet.multipart.FileRenamePolicy;

import net.atomarrow.util.FileUtil;
 
/**
 * @author BruceZCQ
 */
public class RandomFileRenamePolicy  implements FileRenamePolicy  {
 

    @Override
    public File rename(File file) {
        String rename = UUID.randomUUID().toString();
        String path = file.getParent();
        if (!path.endsWith("/")) {
            path += "/";
        }
        return (new File(path,rename+"."+FileUtil.getFileSuffix(file.getName())));
    }
 
}